﻿
namespace UnknowWorld.CardGame
{
    /// <summary>
    /// 能量
    /// </summary>
    [System.Serializable]
    public class Energy
    {
        /// <summary>
        /// 能量类型
        /// </summary>
        public EnergyType Type { get; set; }
        /// <summary>
        /// 值
        /// </summary>
        public int[] Values { get; set; }

        /// <summary>
        /// 能量值
        /// </summary>
        /// <param name="energy"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        public int EnergyValue(int level)
        {
            int index = level - 1;
            if (index >= Values.Length)
            {
                index = Values.Length - 1;
            }
            if (index < 0)
            {
                return 0;
            }
            return Values[index];
        }

        /// <summary>
        /// 能量类型
        /// </summary>
        /// <param name="energy"></param>
        /// <returns></returns>
        public string EnergyTypeString()
        {
            string typeStr = "";
            switch (Type)
            {
                case EnergyType.Magic:
                    typeStr = "魔法值";
                    break;
                case EnergyType.Stamina:
                    typeStr = "耐力值";
                    break;
            }
            return typeStr;
        }

        /// <summary>
        /// 格式化描述
        /// </summary>
        /// <returns></returns>
        public string FormatDescription(int level)
        {
            string des = "";
            switch (Type)
            {
                case EnergyType.Magic:
                    des = string.Format("\n\u3000[消耗<color=red>{0}</color>魔法值]", EnergyValue(level));
                    break;
                case EnergyType.Stamina:
                    des = string.Format("\n\u3000[消耗<color=red>{0}</color>耐力值]", EnergyValue(level));
                    break;
            }
            return des;
        }
    }

    /// <summary>
    /// 能量类型
    /// </summary>
    public enum EnergyType
    { 
        Magic,
        Stamina,
    }
}